use dbus;
use dbus::arg;
use dbus::nonblock;

pub trait OrgBluezMedia1 {
    fn register_endpoint(
        &self,
        endpoint: dbus::Path,
        properties: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<()>;
    fn unregister_endpoint(&self, endpoint: dbus::Path) -> nonblock::MethodReply<()>;
    fn register_player(
        &self,
        player: dbus::Path,
        properties: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<()>;
    fn unregister_player(&self, player: dbus::Path) -> nonblock::MethodReply<()>;
}

impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target = T>> OrgBluezMedia1
    for nonblock::Proxy<'a, C>
{
    fn register_endpoint(
        &self,
        endpoint: dbus::Path,
        properties: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<()> {
        self.method_call(
            "org.bluez.Media1",
            "RegisterEndpoint",
            (endpoint, properties),
        )
    }

    fn unregister_endpoint(&self, endpoint: dbus::Path) -> nonblock::MethodReply<()> {
        self.method_call("org.bluez.Media1", "UnregisterEndpoint", (endpoint,))
    }

    fn register_player(
        &self,
        player: dbus::Path,
        properties: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<()> {
        self.method_call("org.bluez.Media1", "RegisterPlayer", (player, properties))
    }

    fn unregister_player(&self, player: dbus::Path) -> nonblock::MethodReply<()> {
        self.method_call("org.bluez.Media1", "UnregisterPlayer", (player,))
    }
}
